/*
 * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2023-2023. All rights reserved.
 */

#include "IPConfigSetting.h"

namespace BurnDlg {

IPConfigSetting::IPConfigSetting(QWidget *parent)
    : QWidget(parent),
      ui(new Ui::BoardIPConfig())
{
    ui->setupUi(this);
    InitUi();
}

IPConfigSetting::~IPConfigSetting()
{
}

void IPConfigSetting::InitUi()
{
    this->setWindowFlags(this->windowFlags() & (~static_cast<int>(Qt::WindowMinMaxButtonsHint)));
    setFixedSize(this->width(), this->height());
    connect(ui->pbSave, SIGNAL(clicked(bool)), this, SLOT(SlotSaveClicked(bool)));
}

void IPConfigSetting::SetIPAddress(const QString &address, const QString &subnetMask,
    const QString &gateway) const
{
    ui->widgetIPAddress->SetIP(address);
    ui->widgetSubnetMask->SetIP(subnetMask);
    ui->widgetGateway->SetIP(gateway);
}

void IPConfigSetting::SlotSaveClicked(bool)
{
    QString address = ui->widgetIPAddress->GetIP();
    QString subnetMask = ui->widgetSubnetMask->GetIP();
    QString gateway = ui->widgetGateway->GetIP();
    emit SignalSaveAddress(address, subnetMask, gateway);
    this->close();
}

}
